//baseUrl
function getBaseUrl(){
    return document.getElementsByTagName('base')[0].href + 'index.php';
}
function U(str,params){
     var _url = '';
    if($.trim(str) == '#'){
        return "#";
    }else{
        var _url = getBaseUrl() + '/' + $.trim(str);
        if(typeof params === 'object'){
            for(var _p in params){
                _url += '/' + _p + '/' + params[_p];
            }
        }
        return _url;
    }
}
function unique(arr) {
    var result = [], hash = {};
    for (var i = 0, elem; (elem = arr[i]) != null; i++) {
        if (!hash[elem]) {
            result.push(elem);
            hash[elem] = true;
        }
    }
    return result;
}

function classNames(names){
    if(typeof names !== 'object'){
        return '';
    }else{
        var _classname = '';
        for(var _p in names){
            if(names[_p]){
                _classname += _p + ' ';
            }
        }
        return _classname;
    }
}

function _get(url, back){
    $.get(url, function(data){
        if(typeof back.res_back == "function") back.res_back();
        if(typeof back.data_back == "function") back.data_back(data);
    })
}

function _post(url, data, back){
    $.post(url, data).done(function(data){
        if(typeof back.res_back == "function") back.res_back();
        if(typeof back.data_back == "function") back.data_back(data);
    }).error(function(){
        if(typeof back.error == "function") back.error();
    });
}